/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Interface.Edicao;

import static Interface.Global.aux;
import Modelo.Edicao.Edicao;
import Modelo.Evento.Evento;
import Util.ExcecaoInstanciaNaoEncontrada;
import java.awt.Component;

import java.sql.Date;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author ana.siena
 */
public class AlterarEdicao extends javax.swing.JFrame {
    
    private long codEven;
    private int numeroEdicao;
    private String locEdicao;
    private Calendar dataIniEdicao;
    private Calendar dataFimEdicao;
    private int nroInscritosEdicao;
    private Edicao ed;
    
    long novoCodEvento;
    int novoNroEdicao;
    String novaLocalEdicao;
    Calendar novaDataIniEdicao;
    Calendar novaDataFimEdicao;
    int novoNroInscritosEdicao;

    /**
     * Creates new form AlterarEdicao
     */
    public AlterarEdicao() {
        initComponents();
        init();
    }
    
    private void init(){
	setVisible(true);
        setTitle("Alterar Edicao");
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        //Preenche combobox do evento
        ArrayList <Evento> vetorCodEvento = new ArrayList <Evento>();
        vetorCodEvento = (ArrayList<Evento>) aux.buscarTodosEventos();
        
        for(int i=0; i<vetorCodEvento.size();i++)
        {
            codEvento.addItem(vetorCodEvento.get(i).getCodEvento());
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        codEvento = new javax.swing.JComboBox();
        nroEdicao = new javax.swing.JComboBox();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        codigoEvento = new javax.swing.JTextField();
        nroEdicao1 = new javax.swing.JTextField();
        localEdicao = new javax.swing.JTextField();
        dataInicEdicao = new javax.swing.JTextField();
        dataTermEdicao = new javax.swing.JTextField();
        nroVagasEdicao = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        codigoEvento1 = new javax.swing.JTextField();
        nroEdicao2 = new javax.swing.JTextField();
        localEdicao1 = new javax.swing.JTextField();
        dataInicEdicao1 = new javax.swing.JTextField();
        dataTermEdicao1 = new javax.swing.JTextField();
        nroVagasEdicao1 = new javax.swing.JTextField();
        botaoAlterar = new javax.swing.JButton();
        botaoRetornar = new javax.swing.JButton();
        botaoConsultar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel1.setText("Alterar uma Edição");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Edição a ser alterada"));

        jLabel3.setText("Código do evento:");

        jLabel4.setText("Número Edição:");

        codEvento.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                codEventoActionPerformed(evt);
            }
        });

        nroEdicao.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                nroEdicaoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(codEvento, 0, 114, Short.MAX_VALUE)
                    .addComponent(nroEdicao, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(124, 124, 124))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(codEvento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(nroEdicao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados sobre a edição"));

        jLabel2.setText("Código do evento:");

        jLabel5.setText("Número da edição:");

        jLabel6.setText("Local:");

        jLabel7.setText("Data de início:");

        jLabel8.setText("Data de término:");

        jLabel9.setText("Número de inscritos:");

        codigoEvento.setEnabled(false);
        codigoEvento.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                codigoEventoActionPerformed(evt);
            }
        });

        nroEdicao1.setEnabled(false);
        nroEdicao1.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                nroEdicao1ActionPerformed(evt);
            }
        });

        localEdicao.setEnabled(false);
        localEdicao.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                localEdicaoActionPerformed(evt);
            }
        });

        dataInicEdicao.setEnabled(false);
        dataInicEdicao.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                dataInicEdicaoActionPerformed(evt);
            }
        });

        dataTermEdicao.setEnabled(false);
        dataTermEdicao.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                dataTermEdicaoActionPerformed(evt);
            }
        });

        nroVagasEdicao.setEnabled(false);
        nroVagasEdicao.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                nroVagasEdicaoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9)
                    .addComponent(jLabel2))
                .addGap(26, 26, 26)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(codigoEvento, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(nroVagasEdicao, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                        .addComponent(dataInicEdicao, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(localEdicao, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(nroEdicao1)
                        .addComponent(dataTermEdicao)))
                .addContainerGap(55, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(codigoEvento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(nroEdicao1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(localEdicao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(dataInicEdicao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(dataTermEdicao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(nroVagasEdicao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Alterações sobre a edição"));

        jLabel10.setText("Código do evento:");

        jLabel11.setText("Número da edição:");

        jLabel12.setText("Local:");

        jLabel13.setText("Data de início:");

        jLabel14.setText("Data de término:");

        jLabel15.setText("Número de vagas:");

        codigoEvento1.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                //codigoEvento1ActionPerformed(evt);
            }
        });

        nroEdicao2.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                nroEdicao2ActionPerformed(evt);
            }
        });

        localEdicao1.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                localEdicao1ActionPerformed(evt);
            }
        });

        dataInicEdicao1.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                dataInicEdicao1ActionPerformed(evt);
            }
        });

        dataTermEdicao1.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                dataTermEdicao1ActionPerformed(evt);
            }
        });

        nroVagasEdicao1.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                nroVagasEdicao1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12)
                    .addComponent(jLabel13)
                    .addComponent(jLabel14)
                    .addComponent(jLabel15)
                    .addComponent(jLabel10))
                .addGap(26, 26, 26)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(codigoEvento1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(nroVagasEdicao1, javax.swing.GroupLayout.DEFAULT_SIZE, 187, Short.MAX_VALUE)
                        .addComponent(dataInicEdicao1, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(localEdicao1, javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(nroEdicao2)
                        .addComponent(dataTermEdicao1)))
                .addContainerGap(55, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(codigoEvento1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(nroEdicao2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(localEdicao1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(dataInicEdicao1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(dataTermEdicao1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(nroVagasEdicao1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        botaoAlterar.setText("Alterar");
        botaoAlterar.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    botaoAlterarActionPerformed(evt);
                } catch (ExcecaoInstanciaNaoEncontrada ex) {
                    Logger.getLogger(AlterarEdicao.class.getName()).log(Level.SEVERE, null, ex);
                    Component frame = null;
                    JOptionPane.showMessageDialog(frame,ex.getMessage());
                }
            }
        });

        botaoRetornar.setText("Retornar");
        botaoRetornar.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoRetornarActionPerformed(evt);
            }
        });

        botaoConsultar.setText("Consultar");
        botaoConsultar.addActionListener(new java.awt.event.ActionListener() {
            @Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
                try {
                    botaoConsultarActionPerformed(evt);
                } catch (ExcecaoInstanciaNaoEncontrada ex) {
                    Logger.getLogger(AlterarEdicao.class.getName()).log(Level.SEVERE, null, ex);
                    Component frame = null;
                    JOptionPane.showMessageDialog(frame,ex.getMessage());
                }
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(133, 133, 133))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(botaoRetornar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botaoConsultar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botaoAlterar)
                                .addContainerGap())))))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addContainerGap()))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 363, Short.MAX_VALUE)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botaoAlterar)
                    .addComponent(botaoRetornar)
                    .addComponent(botaoConsultar))
                .addGap(10, 10, 10))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(46, 46, 46)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(275, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void dataInicEdicaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dataInicEdicaoActionPerformed
        
    }//GEN-LAST:event_dataInicEdicaoActionPerformed

    private void dataInicEdicao1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dataInicEdicao1ActionPerformed
       
    }//GEN-LAST:event_dataInicEdicao1ActionPerformed

    private void botaoAlterarActionPerformed(java.awt.event.ActionEvent evt) throws ExcecaoInstanciaNaoEncontrada {//GEN-FIRST:event_botaoAlterarActionPerformed
        
        DateFormat dataInic = new SimpleDateFormat("dd/MM/yyyy");
        this.novaDataIniEdicao = Calendar.getInstance();
                try {        
                    this.novaDataIniEdicao.setTime(dataInic.parse(this.dataInicEdicao1.getText()));
                } catch (ParseException ex) {
                    Logger.getLogger(AlterarEdicao.class.getName()).log(Level.SEVERE, null, ex);
                    Component frame = null;
                    JOptionPane.showMessageDialog(frame,ex.getMessage());
                }
                
        novoCodEvento = Long.parseLong(codigoEvento1.getText());
        novoNroEdicao = Integer.parseInt(this.nroEdicao2.getText());
        novaLocalEdicao  = localEdicao1.getText();
        
        DateFormat dataTerm = new SimpleDateFormat("dd/MM/yyyy");
                this.novaDataFimEdicao = Calendar.getInstance();
                try {        
                    this.novaDataFimEdicao.setTime(dataTerm.parse(this.dataTermEdicao1.getText()));
                } catch (ParseException ex) {
                    Logger.getLogger(AlterarEdicao.class.getName()).log(Level.SEVERE, null, ex);
                    Component frame = null;
                    JOptionPane.showMessageDialog(frame,ex.getMessage());
                }
                
        Edicao edicao1 = new Edicao(novoCodEvento,ed.getNroEdicao(),novaLocalEdicao,novaDataIniEdicao,novaDataFimEdicao,novoNroInscritosEdicao);
        aux.updateEdicao(edicao1);
    }//GEN-LAST:event_botaoAlterarActionPerformed

    private void botaoRetornarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoRetornarActionPerformed
        
        new MenuEdicao().setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_botaoRetornarActionPerformed

    private void botaoConsultarActionPerformed(java.awt.event.ActionEvent evt) throws ExcecaoInstanciaNaoEncontrada {//GEN-FIRST:event_botaoConsultarActionPerformed
        numeroEdicao = Integer.parseInt(""+ this.nroEdicao.getSelectedItem());
        codEven = Long.parseLong(""+ codEvento.getSelectedItem());
    	
    	ed = aux.buscaEdicao(codEven, numeroEdicao);
        
        codigoEvento.setText(Long.toString(ed.getCodEvento()));
        nroEdicao1.setText(Integer.toString(ed.getNroEdicao()));
        localEdicao.setText(ed.getLocalEdicao());
        DateFormat df = new SimpleDateFormat("MM/dd/yyyy");       
        String data = df.format(new Date(ed.getDataIniEdicao().getTimeInMillis()));
        dataInicEdicao.setText(data);
        String data1 = df.format(new Date(ed.getDataFimEdicao().getTimeInMillis()));
        dataTermEdicao.setText(data);
        nroVagasEdicao.setText(Integer.toString(ed.getNroInscritosEdicao()));
        
        
        this.codigoEvento1.setText(Long.toString(ed.getCodEvento()));
        this.nroEdicao2.setText(Integer.toString(ed.getNroEdicao()));
        this.localEdicao1.setText(ed.getLocalEdicao());
        this.dataInicEdicao1.setText(data);
        this.dataTermEdicao1.setText(data1);
        this.nroVagasEdicao1.setText(Integer.toString(ed.getNroInscritosEdicao()));
                
    }//GEN-LAST:event_botaoConsultarActionPerformed

    private void nroEdicao1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nroEdicao1ActionPerformed
    }//GEN-LAST:event_nroEdicao1ActionPerformed

    private void localEdicaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_localEdicaoActionPerformed
    }//GEN-LAST:event_localEdicaoActionPerformed

    private void dataTermEdicaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dataTermEdicaoActionPerformed
    }//GEN-LAST:event_dataTermEdicaoActionPerformed

    private void nroVagasEdicaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nroVagasEdicaoActionPerformed
    }//GEN-LAST:event_nroVagasEdicaoActionPerformed

    private void codigoEventoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_codigoEvento1ActionPerformed
       
    }//GEN-LAST:event_codigoEvento1ActionPerformed

    private void nroEdicao2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nroEdicao2ActionPerformed
        
    }//GEN-LAST:event_nroEdicao2ActionPerformed

    private void localEdicao1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_localEdicao1ActionPerformed
       
    }//GEN-LAST:event_localEdicao1ActionPerformed

    private void dataTermEdicao1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dataTermEdicao1ActionPerformed
        
    }//GEN-LAST:event_dataTermEdicao1ActionPerformed

    private void nroVagasEdicao1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nroVagasEdicao1ActionPerformed
        
    }//GEN-LAST:event_nroVagasEdicao1ActionPerformed

    private void codEventoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_codEventoActionPerformed
        
        codEven = Long.parseLong(""+ codEvento.getSelectedItem());
               
        if(codEven == 0){
            System.out.println("Não tem nenhum evento selecionado");
        }
        else{
            //Preenche combobox do edicao
            ArrayList <Edicao> vetorCodEdicao = new ArrayList <Edicao>();
            vetorCodEdicao = (ArrayList<Edicao>) aux.buscaEdicoesPorEvento(codEven);
            
            nroEdicao.removeAllItems();
            for(int i=0; i<vetorCodEdicao.size();i++)
            {
                nroEdicao.addItem(vetorCodEdicao.get(i).getNroEdicao());
            }
            
        }
    }//GEN-LAST:event_codEventoActionPerformed

    private void nroEdicaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nroEdicaoActionPerformed
        
    }//GEN-LAST:event_nroEdicaoActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoAlterar;
    private javax.swing.JButton botaoConsultar;
    private javax.swing.JButton botaoRetornar;
    private javax.swing.JComboBox codEvento;
    private javax.swing.JTextField codigoEvento;
    private javax.swing.JTextField codigoEvento1;
    private javax.swing.JTextField dataInicEdicao;
    private javax.swing.JTextField dataInicEdicao1;
    private javax.swing.JTextField dataTermEdicao;
    private javax.swing.JTextField dataTermEdicao1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField localEdicao;
    private javax.swing.JTextField localEdicao1;
    private javax.swing.JComboBox nroEdicao;
    private javax.swing.JTextField nroEdicao1;
    private javax.swing.JTextField nroEdicao2;
    private javax.swing.JTextField nroVagasEdicao;
    private javax.swing.JTextField nroVagasEdicao1;
    // End of variables declaration//GEN-END:variables
}
